/*
 * @Author: your name
 * @Date: 2020-08-24 14:36:44
 * @LastEditTime: 2020-08-28 16:15:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \exam\react-exam\src\service\questions.ts
 */
import request from '../utils/request';

/* 引入接口类型 */
import { /* AddQuestionItem, */ ConditionItem, UpdateItem, ExamStudent } from '../utils/interface';

/* 获取所有的试题类型 */
export let getQuestionsType=()=>{
    return request.get('/exam/getQuestionsType');
}

/* 获取所有的课程 */
export let getSubjectList=()=>{
    return request.get('/exam/subject');
}

/* 获取所有的考试类型 */
export let getExamType=()=>{
    return request.get('/exam/examType');
}

/* 添加试题接口 
    参数：  questions_type_id  必传  试题类型id
            questions_stem  必传  题干
            subject_id  必传  课程id
            exam_id  必传  考试类型id
            user_id  必传  用户id
            questions_answer  必传  题目答案
            title  必传  试题的标题
 */
export let  addQuestions=(questions_type_id: string,
    questions_stem: string,
    subject_id: string,
    exam_id: string,
    user_id: string,
    questions_answer: string,
    title: string)=>{
   /*  console.log('添加试题接口...',questions_type_id,
    questions_stem,
    subject_id,
    exam_id,
    user_id,
    questions_answer,
    title); */
    
    return request.post('/exam/questions',{questions_type_id,
    questions_stem,
    subject_id,
    exam_id,
    user_id,
    questions_answer,
    title});
}

/* 添加试题类型  text:必传 试题名称   sort:必传  试题序号 */
export let  addInsertQuestionsType=(text:string,sort: string)=>{
    return request.get('/exam/insertQuestionsType',{params: {text, sort}});
}

/* 删除指定的试题类型  id:试题类型的id */
export let  delQuestionsType=(id:string)=>{
    return request.post('/exam/delQuestionsType',{id});
}

/* 获取所有的试题 */
export let getQuestionsList=()=>{
    return request.get('/exam/questions/new');
}

/* 
    按条件获取试题
    参数：  questions_id  可传  试题id
            questions_type_id  可传  课程类型id
            subject_id  可传  课程id
            exam_id  可传  考试类型id
 */
export let getCondition=(params:ConditionItem)=>{
    return request.get('/exam/questions/condition',{params});
}


export let updateQuestions=(params:UpdateItem)=>{
    return request.put('/exam/questions/update',params);
}

//待批班级

export let getExamstudent=(params?:ExamStudent)=>{
    return request.get('exam/student',{params:{...params}})
}